package com.bjpowernode.boss.web.controller;

import com.bjpowernode.boss.web.dto.LoginResultDto;
import com.bjpowernode.boss.web.model.query.LoginQuery;
import com.bjpowernode.boss.web.model.response.CommonResult;
import com.bjpowernode.boss.web.service.impl.OperatorServiceImpl;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.security.PrivateKey;

@RestController
public class OperatorController {

    //注入service
    @Resource
    private OperatorServiceImpl operatorService;

    //参数验证使用Bean Validation，，，，@Validated验证注解
    @PostMapping("/operator/access")
    public CommonResult accessToken(@RequestBody @Validated LoginQuery loginQuery) {
        //调用service，查询用户是否存在（为登录做准备）
        LoginResultDto loginResultDto = operatorService.login(loginQuery);
        //返回包含了LoginResultDto的commonResult对象
        return CommonResult.succ(loginResultDto);
    }
}
